#!/usr/bin/python
# -*- coding: utf-8 -*-

import  multiprocessing



def mulprocess(fn,data,nprocess):

    dataset = []
    #拆分数据
    quantity = len(data)
    perquantity = quantity // nprocess

    index = 0
    percounter = 0


    for item in data:

        dataset[index].apend(item)
        percounter += 1
        if percounter >= perquantity:
            index+=1

        if index >= nprocess:
            index = nprocess - 1


    for i in range(nprocess):
        p = multiprocessing.Process(target=fn,args=(dataset[i],))
        p.start()


    print('start all process...')



import time

def fn(name):
    print(name)
    time.sleep(0.1)
if __name__ == '__main__':
    a = range(100)

    mulprocess(fn,a,1)
